package cheme.ProcessEditor.Parts.Streams.Tag;

import org.eclipse.draw2d.Label;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.Request;
import org.eclipse.jface.viewers.ICellEditorValidator;

import cheme.ProcessEditor.ValidationEnabledGraphicalViewer;
import cheme.ProcessEditor.DirectEdit.ChemeNumericCellEditor;
import cheme.ProcessEditor.DirectEdit.ChemeTextCellEditor;
import cheme.ProcessEditor.DirectEdit.ChemeTextDirectEditManager;
import cheme.ProcessEditor.DirectEdit.LabelCellEditorLocator;
import cheme.ProcessEditor.DirectEdit.NumericFieldCellEditorValidator;
import cheme.ProcessEditor.DirectEdit.ValidationMessageHandler;
import cheme.ProcessEditor.DirectEdit.WritableFieldCellEditorValidator;
import cheme.ProcessEditor.Figures.FieldFig;
import cheme.ProcessModel.Interpreter.Parsers.ParserFactory;

public class PartQuantityField extends TagComponentFieldPart implements IDragParentOnly
{
	@Override
	protected FieldFig createFigure()
	{
		FieldFig fig = super.createFigure();
		fig.setToolTip(new Label(getModel().getToolTipText()));
		//fig.setToolTip(new Label("A description of the quantity of this component.\n(Double click or press space-bar to edit)"));
		return fig;
	}
	
	@Override
	public DragTracker getDragTracker(Request request)
	{
		return new ChemeDragEditPartsTracker(this);
	}
	
	protected void performDirectEdit()
	{
		if(manager == null)
		{
			Label l = (Label)getFigure();
			manager = new ChemeTextDirectEditManager(
					this, 
					ChemeNumericCellEditor.class, 
					new LabelCellEditorLocator(l), 
					l, 
					getCellValidator());
		}

		manager.show();
	}
}
